import {
	CSSProperties,
	ForwardRefExoticComponent,
	HTMLAttributes,
	ReactNode,
	RefAttributes,
} from 'react';

export type ToastPosition = 'top' | 'middle' | 'bottom';

export interface ToastProps extends HTMLAttributes<HTMLDivElement> {
	visible?: boolean;
	mountTo?: HTMLElement | (() => HTMLElement) | false;
	position?: ToastPosition;
	message?: string;
	icon?: ReactNode;
	duration?: number;
	forbidClick?: boolean;
	clickCloseable?: boolean;
	overlay?: boolean;
	overlayClassName?: string;
	overlayStyle?: CSSProperties;
	overlayCloseable?: boolean;
	onHide?: () => void;
	onAfterHide?: () => void;
	onShow?: () => void;
	onAfterShow?: () => void;
}

export type ToastComponent = ForwardRefExoticComponent<
	ToastProps & RefAttributes<HTMLDivElement>
>;

export interface ToastExportExtra {
	show: (props: string | ToastProps) => ToastInstance;
	loading: (props: string | ToastProps) => ToastInstance;
	success: (props: string | ToastProps) => ToastInstance;
	fail: (props: string | ToastProps) => ToastInstance;
	allowMultiple: (allow: boolean) => void;
	clear: () => void;
}

export interface ToastInstance {
	update: (props: ToastProps) => void;
	clear: () => void;
}
